package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.product.RCFullServiceProductEntry;
import com.shrct.businessprocess.product.impl.RCFullServiceProductEntryImpl;
import com.shrct.businessprocess.project.RCProjectMoney;
import com.shrct.businessprocess.purchase.RCServiceAcceptItem;
import com.shrct.businessprocess.purchase.RCServicePurchaseOrderAccept;
import com.shrct.businessprocess.purchase.impl.RCServicePurchaseOrderAcceptImpl;
import com.shrct.businessprocess.purchase.proxy.RCServiceAcceptItemProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCSERVICEACCEPTITEM_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcserviceacceptitem")
public class RCServiceAcceptItemImpl extends BaseModelObject implements RCServiceAcceptItem {
  public RCServiceAcceptItemImpl() {
    super();
  }
  
  public RCServiceAcceptItemImpl(final RCServicePurchaseOrderAccept accept) {
    super();
    this.accept = accept;
  }
  
  @JoinColumn(name = "accept_id")
  @ManyToOne(targetEntity = RCServicePurchaseOrderAcceptImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCServicePurchaseOrderAccept accept;
  
  public RCServicePurchaseOrderAccept getAccept() {
    return this.accept;
  }
  
  public RCServiceAcceptItem setAccept(final RCServicePurchaseOrderAccept accept) {
    this.accept = accept;
    return this;			
    
  }
  
  @JoinColumn(name = "productEntry_id")
  @ManyToOne(targetEntity = RCFullServiceProductEntryImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCFullServiceProductEntry productEntry;
  
  public RCFullServiceProductEntry getProductEntry() {
    return this.productEntry;
  }
  
  public RCServiceAcceptItem setProductEntry(final RCFullServiceProductEntry productEntry) {
    this.productEntry = productEntry;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "price_amount") ), @AttributeOverride(name = "workaround", column = @Column(name = "price_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "exchange", joinColumns = @JoinColumn(name = "price_exchange") ) )
  private RCProjectMoney price = com.shrct.businessprocess.project.RCProjectMoney.create();
  
  public RCProjectMoney getPrice() {
    return this.price;
  }
  
  public RCServiceAcceptItem setPrice(final RCProjectMoney price) {
    this.price = price;
    return this;			
    
  }
  
  public static RCServiceAcceptItem create(final RCServicePurchaseOrderAccept accept, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCServiceAcceptItem rCServiceAcceptItem = new com.shrct.businessprocess.purchase.impl.RCServiceAcceptItemImpl(
    	accept
    );
    objectFactory.create(rCServiceAcceptItem);
    return rCServiceAcceptItem;			
    
  }
  
  public static RCServiceAcceptItem createRCServiceAcceptItemImpl(final RCServicePurchaseOrderAccept accept, final IObjectFactory objectFactory, final Procedure1<RCServiceAcceptItem> init) {
    com.shrct.businessprocess.purchase.RCServiceAcceptItem rCServiceAcceptItem = new com.shrct.businessprocess.purchase.impl.RCServiceAcceptItemImpl(
    	accept
    );
    objectFactory.create(rCServiceAcceptItem);
    init.apply(rCServiceAcceptItem);
    
    return rCServiceAcceptItem;			
    
  }
  
  public RCServiceAcceptItemProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCServiceAcceptItemProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCServiceAcceptItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
